from .table import CatalogTable, CatalogTableFrom
from .index import CatalogIndex, CatalogIndexFrom
from .function import CatalogFunction, CatalogFunctionFrom

catalog_table = CatalogTable()
catalog_table.load()
catalog_index = CatalogIndex()
catalog_index.load()
catalog_function = CatalogFunction()

catalog_table.insert(CatalogTableFrom('t1', ['id', 'name'], [int, str]))
catalog_table.insert(CatalogTableFrom('t2', ['id', 'name', 'address'], [int, str, str]))
catalog_table.insert(CatalogTableFrom('t3', ['id', 'city', 'area'], [int, str, str]))
catalog_table.insert(CatalogTableFrom('t4', ['id', 'company', 'job'], [int, str, str]))

catalog_index.insert(CatalogIndexFrom('idx', ['id'], 't1'))

catalog_function.insert(CatalogFunctionFrom(function_name='count', arg_count=-1, callback=len, is_agg=True))
catalog_function.insert(CatalogFunctionFrom(function_name='sum', arg_count=-1, callback=sum, is_agg=True))
catalog_function.insert(CatalogFunctionFrom(function_name='avg', arg_count=-1, callback=lambda values: sum(values) / len(values), is_agg=True))
catalog_function.insert(CatalogFunctionFrom(function_name='max', arg_count=-1, callback=max, is_agg=True))
catalog_function.insert(CatalogFunctionFrom(function_name='min', arg_count=-1, callback=min, is_agg=True))